package com.lzq.lottery_system.common.exception;

import com.lzq.lottery_system.common.errorcode.ErrorCode;
import lombok.Data;
import lombok.EqualsAndHashCode;
//@Data会自己生产equals and hashcode方法
@Data
//不写@EqualsAndHashCode(callSuper = true)可能会出现问题
@EqualsAndHashCode(callSuper = true)
public class ControllerException extends RuntimeException{
    /**
     * 异常码
     * @see com.lzq.lottery_system.common.errorcode.ControllerErrorCodeConstants
     */
    private Integer code;
    /**
     * 异常消息
     */
    private String message;

    public ControllerException() {

    }

    public ControllerException(Integer code,String message) {
        this.code = code;
        this.message = message;
    }

    public ControllerException(ErrorCode errorCode) {
        this.code = errorCode.getCode();
        this.message = errorCode.getMsg();
    }
}
